const path = require('path');

function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    chainWebpack: (config) => {
        config.resolve.alias
            .set("@entity",     resolve("src/assets/js/entity"))

            .set("@nav",        resolve("src/components/navigation/Index.vue"))
            .set("@avatar",     resolve("src/components/avatar/Index.vue"))
            .set("@logo",       resolve("src/components/logo/Index.vue"))
            .set("@tag",        resolve("src/components/tag/Index.vue"))
            .set("@footer",     resolve("src/components/footer/Index.vue"))
            .set("@guide",      resolve("src/components/guide/Index.vue"))

            .set("@home",       resolve("src/views/home"))
            .set("@login",      resolve("src/views/login"))
            .set("@publish",    resolve("src/views/publish"))
            .set("@profile",    resolve("src/views/profile"))
            .set("@project",    resolve("src/views/project"))
            .set("@message",    resolve("src/views/message"))

            .set("@axios",      resolve("src/plugins/axios"))
            .set("@ws",         resolve("src/plugins/websocket"))
            .set("@router",     resolve("src/plugins/router"))
            .set("@store",      resolve("src/plugins/store"))
    },
    devServer: {
        host: "0.0.0.0",
        disableHostCheck: true,
        port: 80, // 端口号
        open: false, //配置自动启动浏览器,
        hot: true,
        proxy: {
            "/api": { 
                target: `http://www.olah.com:1000/v1/`, 
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            },
            // "/image": { 
            //     target: `http://${cying.host}:${cying.port}/imgs/`, 
            //     changeOrigin: true,
            //     ws: true,
            //     pathRewrite: {
            //         '^/image': ''
            //     }
            // }
        }
    }
}